[envoy] Add support for HttpBody request#10110
Conversation
Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com>
Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com>
source/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter.h
Outdated
Show resolved
Hide resolved
source/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter.h
Outdated
Show resolved
Hide resolved
source/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter.h
Outdated
Show resolved
Hide resolved
test/extensions/filters/http/grpc_json_transcoder/grpc_json_transcoder_integration_test.cc
Outdated
Show resolved
Hide resolved
| } | ||
|
|
||
| bool done = !readToBuffer(*transcoder_->RequestOutput(), request_prefix_); | ||
| RELEASE_ASSERT(done, "request transcoder should have been done"); |
There was a problem hiding this comment.
Just reject the request with error log? I don't think RELEASE_ASSERT should be done in data path of a filter.
source/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter.cc
Outdated
Show resolved
Hide resolved
| CONSTRUCT_ON_FIRST_USE(Http::LowerCaseString, "trailer"); | ||
| } | ||
|
|
||
| constexpr uint32_t HttpBodyFieldNumber = 2; |
There was a problem hiding this comment.
Can you advice if there is a presence of ProtobufLengthDelimitedField-like constant in protobuf, please? It looks like it's hardcoded as 2 everywhere in the libprotobuf codebase, and all potential helper functions are in internal namespace.
There was a problem hiding this comment.
Yeah I see that is only in internal::WireFormat, can you move this constexpr to the function you use it (there's only one), and add a comment where it is from?
There was a problem hiding this comment.
Done, added additional comment to already present link to wire format documentation.
Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com>
Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com>
|
I feel some part of this PR should go to https://github.com/grpc-ecosystem/grpc-httpjson-transcoding/ directly, thoughts? @qiwzhang |
Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com>
Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com>
…quest-3 Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com>
|
@lizan I can see the benefit of moving some of code to grpc_httpjson_transcoder repo: it will enhance the library to support HttpBody type for both request and response and other callers will benefit from such enhancement. But I also understand that HttpBody translation is different with JSON translation. It seems that it is not easy to fit HttpBody translation code into that library. I am fine to have specific HttpBody translation code here. |
| return status; | ||
| } | ||
|
|
||
| if (method_info->request_body_field_path.empty()) { |
There was a problem hiding this comment.
do we handle case where the request type is HttpBody and http_rule.body() is *?
if so, should the ending block at line 248 move to line 237?
There was a problem hiding this comment.
From reading google cloud's transcoding documentation it looks like "*" body is only applicable to json transcoding:
The special name
*can be used in the body mapping to define that every field not bound by the path template should be mapped to the request body.
There was a problem hiding this comment.
Then, do we support the HttpBody as the gRPC request type?
with auto_mapping =true, we generate a http rule with * body for every grpc method.
There was a problem hiding this comment.
Do you happen to know what is a behavior of Google Cloud in this case?
I'm probably inclined to treat "*" as "" for HttpBody requests.
| return false; | ||
| } | ||
|
|
||
| void JsonTranscoderFilter::createHttpBodyEnvelope(Buffer::Instance& data, uint64_t content_length) { |
There was a problem hiding this comment.
I feel this code is grpc specific, can be moved to grpc util library. it should be unit-tested thoroughly.
There was a problem hiding this comment.
Few concerns:
- It's more protobuf than grpc specific (grpc piece is small and is not a concern)
- I'm not sure it's useful anywhere outside of this filter
I agree though that it's not trivial and I'm adding better test coverage
There was a problem hiding this comment.
Few concerns:
- It's more protobuf than grpc specific (grpc piece is small and is not a concern)
- I'm not sure it's useful anywhere outside of this filter
I agree though that it's not trivial and I'm adding better test coverage
This is both grpc and protobuf specific because of the grpc framing part. Ideally it should be in the transcoding library, and a fuzz test should be added too.
There was a problem hiding this comment.
gRPC-specific code was moved to shared library so it's re-used with http1 reverse bridge.
HttpBody protobuf-specific code was covered by tests for the edge cases.
I'm not sure what would be a benefit of a fuzz testing in this case (user input is limited and well-defined).
| // Embedded messages are treated the same way as strings (wire type 2). | ||
| constexpr uint32_t ProtobufLengthDelimitedField = 2; | ||
|
|
||
| std::string request_prefix = request_prefix_.toString(); |
There was a problem hiding this comment.
Not quite understand what request_prefix is for? could not add some examples in the comment
…quest-3 Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com>
|
This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
|
not stable, I'm back from OOO. |
Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com>
…quest-3 Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com>
Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com>
Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com>
|
code LGTM, can you fix CI? |
…quest-3 Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com>
|
|
Description: Add support for
google.api.HttpBodymessage type in requests.Support both unary and streaming requests.
Unary requests currently require filter to buffer the whole request before continue.
Streaming requests pass data to backend without any intermediate buffering at all.
Risk Level: Medium
Testing: Add unit and integration tests
Docs Changes: none
Release Notes: added
Fixes #10057